﻿
$(document).ready(function () {
    $("body").css("display", "none");
    $("body").fadeIn(200);
    var _faded = false;
    $("form").submit(function (e) {
        var errors = $('.input-validation-error');
        if ($("#errorsAlert") != null) {
            $("#errorsAlert").remove(); 
        }
        if (errors.length > 0) {
            $('legend').after('<div id="errorsAlert" class="alert hide alert-block alert-error fade in"><a type="button" class="close" data-dismiss="alert">×</a><h4 class="alert-heading">Oops! You got an error!</h4><p>Please ensure you\'ve answered all question highlighted in red below, and then click \'Continue\' again.</p></div>');
            $("#errorsAlert").stop(true, true).fadeIn({ duration: 'slow', queue: false }).css('display', 'none').slideDown('slow');
            $("#errorsAlert .close").click(function () {
                $("#errorsAlert").stop(true, true).fadeOut({ duration: 'slow', queue: false }).slideUp('slow');
            });
            $("#errorsAlert").focus();
        }
        else {
        /*
            if (!_faded) {
                e.preventDefault();
                $("body").fadeOut(400, function () {
                    _faded = true;
                    $('form').submit();
                });
            }
        */
        }
    });
});